import Vue from 'vue'
import VueRouter from 'vue-router'
import index from '../views/index'
import login from '../views/index/login'
import childIndex from '../views/index/childIndex'
import shopping from '../views/shopping'
import Class from '../views/Class'
import cooperation from '../views/cooperation'
import connectUs from "../views/cooperation/connectUs";
import enterprise from "../views/cooperation/enterprise"
import college from "../views/cooperation/college"
import inheritor from "../views/cooperation/inheritor"
import courseDetail from '../views/class/courseDetail'
import userCenter from '../views/index/userCenter'
import create from '../views/index/create'

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
   { path: '/', redirect: '/index' },

  {
    path:'/index',
    component:index,
    redirect: '/login',
    children:[
       {path:'/childIndex', component:childIndex},
       {path:'/login', component:login},
       {path:'/shopping', component:shopping},
       {path:'/Class', component:Class},
       {path:'/courseDetail', component:courseDetail},
       {path:'/cooperation', component:cooperation},
        {path: '/connectUs', component: connectUs},
        {path: '/inheritor', component: inheritor},
        {path: '/enterprise', component: enterprise},
        {path: '/college', component: college},

       {path:'/userCenter', component:userCenter,
        children:[
          {path:'/create', component:create},
        ]
       },

    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
